<?php

/**
 * @Author: xuebingsi
 * @Date:   2018-07-09 16:08:56
 * @Last Modified by:   zhibinm
 * @Last Modified time: 2018-07-24 18:15:20
 */
// api  两个系统之间的数据交互
// function getIp(){
// 	if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown"))
// 	$ip = getenv("HTTP_CLIENT_IP");
// 	else if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown"))
// 	$ip = getenv("HTTP_X_FORWARDED_FOR");
// 	else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown"))
// 	$ip = getenv("REMOTE_ADDR");
// 	else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], "unknown"))
// 	$ip = $_SERVER['REMOTE_ADDR'];
// 	else
// 	$ip = "unknown";
// 	return($ip);
// }


// var_dump(getIp());exit;
// // 异步  js客户端  php服务端
// $ip = "61.150.2.242";

// $url = "http://ip.taobao.com/service/getIpInfo.php?ip=".$ip;

// $data = file_get_contents($url);

// var_dump(json_decode($data));
// 

$url = "http://www.abc.com/v1/index/getUserInfo?uid=1";

// $method = "post";

$appcode = "ab7bfa4f7d544241998ea5d8a8ddb028";

$headers = array();

array_push($headers, "Authorization:APPCODE " . $appcode);

$post_data  = ['phone'=>1892,'xbs'=>098098098];

// $headers = array("APPCODE: www.abc.com");  

$curl = curl_init();

curl_setopt($curl, CURLOPT_POST, 1);

// curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");

curl_setopt($curl, CURLOPT_URL, $url);

curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
// 
// curl_setopt($curl, CURLOPT_FAILONERROR, false);

curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);

// curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

// curl_setopt($curl, CURLOPT_HEADER, false);


$data= curl_exec($curl);

// echo($data);

// var_dump(json_decode($data,true));